package cn.yzx.pethome.system.emp.service.impl;

import cn.yzx.pethome.system.emp.domain.Employee;
import cn.yzx.pethome.system.emp.mapper.EmployeeMapper;
import cn.yzx.pethome.system.emp.service.IEmployeeService;
import cn.yzx.pethome.base.service.impl.BaseServiceImpl;
import cn.yzx.pethome.utils.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yzx
 * @since 2023-01-17
 */
@Service
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public void delete(Long id) {
        Employee emp = employeeMapper.findOne(id);
        if (emp.getState() == null || emp.getState() == 0){
            employeeMapper.delete(id);
        }else {
            throw new BusinessException("请禁用后删除");
        }
    }
}
